import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import * as pkg from "./package.json";

export default defineConfig({
  plugins: [vue(), vueJsx()],
  build: {
    lib: {
      entry: "src/index.ts",
      name: "qqlx-ui",
      fileName: (format) => `qqlx-ui.${format}.js`,
    },
    rollupOptions: {
      external: [...Object.keys(pkg.peerDependencies || {}), "quasar/src/css/index.sass", "qqlx-core", "qqlx-cdk"],
      output: {
        globals: {
          vue: "Vue",
          quasar: "Quasar",
          "qqlx-core": "QqlxCore",
          "qqlx-cdk": "QqlxCdk",
        },
      },
    },
    // 禁用 CSS 代码分割
    cssCodeSplit: false,
  },
});
